import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:provider/provider.dart';
import 'package:s_mankey/config/resource_mananger.dart';
import 'package:s_mankey/config/storage_manager.dart';
import 'package:s_mankey/provider/provider_widget.dart';
import 'package:s_mankey/service/smonkey_repository.dart';
import 'package:s_mankey/view_model/home_vmodel.dart';


class HomeSwiper extends StatefulWidget {

  final datas;
  HomeSwiper({@required this.datas});

  @override
  _HomeSwiper createState() => _HomeSwiper();
}

class _HomeSwiper extends State<HomeSwiper> {


  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
//    var headers = {'token': StorageManager.sharedPreferences.getString(AppGlobalNae.USERDATA)};
//    print('heasers${headers}');
    return PhysicalModel(
        borderRadius: BorderRadius.circular(20),
        clipBehavior: Clip.antiAlias,
        color: Colors.transparent,
        child: Container(
          padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
          height: 150,
          child:
          Swiper(
            itemCount: widget.datas.length,
            autoplayDelay: 3000,
            autoplay: false,
            pagination: new SwiperPagination(
                builder: DotSwiperPaginationBuilder(
                  color: Colors.black54,
                  activeColor: Colors.white,
                )),
//                  loop: true,
            itemBuilder: (BuildContext context, int index) {
              return new Image.network(
                widget.datas[index]['image_url'],
                fit: BoxFit.fill,
              );
            },
            onTap: (index){
              print('点击了第$index张图片');
            },
          ),
        ),
      );
  }

}